package com.tjise.oss.controller;

import com.tjise.commonutils.R;
import com.tjise.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: tjise_parent
 * @description: Oss的控制访问
 * @author: 郑朝文
 * @create: 2021-06-22 17:07
 **/

@Api(description = "上传文件的功能")
@RestController
@RequestMapping("/eduoss/fileoss")

public class OssController {
    @Autowired
    private OssService ossService;

    // 上传头像的方法
    @ApiOperation("郑朝文写的上传到阿里云的图片")
    @PostMapping
    public R uploadOddFile(MultipartFile file) {
        // 获取到上传的文件
        // 返回上传到oss的路径
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url", url);
    }


}


